﻿using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Controls.Renderers.Windows
{
    public class GridColumnRenderer : ContentElementRenderer<GridColumn, IGridColumnRenderer>, IGridColumnRenderer
    {
        public void RenderGridColumnDefinition(GridColumn control, CodeWriter writer)
        {
            writer.WriteBeginTag("ColumnDefinition");

            writer.WriteAttribute("Width", control.Width);
            writer.WriteAttribute("MaxWidth", control.MaxWidth);
            writer.WriteAttribute("MinWidth", control.MinWidth);

            writer.WriteFullEnd();
        }

        protected override void OnRenderUiXmlContent(GridColumn control, CodeWriter writer)
        {
            int ri = 0;
            foreach (Control c in control.Controls)
            {
                c.GridColumn = control.GridColumnNr;
                c.GridRow = ri;
                c.RenderUiXml(writer);
                ri++;
            }
        }
    }
}